/* 
 * File:   Environment.h
 * Author: Ben
 *
 * Created on November 2, 2012, 1:29 PM
 */

#ifndef ENVIRONMENT_H
#define	ENVIRONMENT_H

#include <vector>
#include "EnvCell.h"
#include "Agent.h"

#define NUM_STARTING_PARTICLES_PER_CELL 5 
#define BOARD_ROWS 15
#define BOARD_COLUMNS 15
#define TOTAL_STARTING_PARTICLES NUM_STARTING_PARTICLES_PER_CELL*BOARD_COLUMNS

/**
 * 1) Contain a 2D vector of EnvironCells
 * 2) Function to print environment
 * 3) Reset environment
 * 4) Data member: NumOfParticles
 * 5) Function to account for particles
 *      *Verify each particle is referenced only once
 *      *Verify each particle is referenced
 *              *AKA ensure there is currently the same number of particles
 *               as when the program started
 * 6) Function to count number of particles
 * 
 */

class Environment {
private:
    
    /**
     * Data member which holds all cells
     */
    static std::vector<std::vector<EnvCell*> > m_ParticleBoard;
    /**
     * When this function is completed, all cells will hold zero particles.
     * No cells are deleted.
     */
    void cleanBoard();
    /**
     * Deallocates all memory for m_ParticleBoard
     */
    void deleteBoard();

public:
    /**
     * Default constructor
     */
    Environment();
    /**
     * Default destructor
     */
    ~Environment();
    /**
     * Places all particles on the top row. Resets board to initial value
     * @return True if successful
     */
    bool resetBoard();
    /**
     * Outputs contents of board. Includes number of particles and number of 
     * agents per cell
     */
    void printBoard();
    /**
     * Verifies the ID of each particle exists exactly once in the board
     * @return True if all particles are accounted for
     */
    bool accountParticles();
    /**
     * Gets the cell at specified row and column of board
     * @param row The desired row
     * @param col The desired column
     * @return The desired cell
     */
    static EnvCell* getCell(int row, int col);
    /**
     * Counts the total number of particles in the board
     * @return Total count of particles
     */
    int countParticles();
    
};

#endif	/* ENVIRONMENT_H */

